home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_351 / pdc / libsrc.lzh / LibSrc / Math / sign.c < prev    next >
C/C++ Source or Header  |  1990-04-07  |  2KB  |  72 lines

  1. /************************************************************************
  2.  *                                                                      *
  3.  *                              N O T I C E                             *
  4.  *                                                                      *
  5.  *                      Copyright Abandoned, 1987, Fred Fish            *
  6.  *                                                                      *
  7.  *      This previously copyrighted work has been placed into the       *
  8.  *      public domain by the author (Fred Fish) and may be freely used  *
  9.  *      for any purpose, private or commercial.  I would appreciate     *
  10.  *      it, as a courtesy, if this notice is left in all copies and     *
  11.  *      derivative works.  Thank you, and enjoy...                      *
  12.  *                                                                      *
  13.  *      The author makes no warranty of any kind with respect to this   *
  14.  *      product and explicitly disclaims any implied warranties of      *
  15.  *      merchantability or fitness for any particular purpose.          *
  16.  *                                                                      *
  17.  ************************************************************************
  18.  */
  19.  
  20. /*
  21.  *  FUNCTION
  22.  *
  23.  *      sign   transfer of sign
  24.  *
  25.  *  KEY WORDS
  26.  *
  27.  *      sign
  28.  *      machine independent routines
  29.  *      math libraries
  30.  *
  31.  *  DESCRIPTION
  32.  *
  33.  *      Returns first argument with same sign as second argument.
  34.  *
  35.  *  USAGE
  36.  *
  37.  *      double sign (x, y)
  38.  *      double x;
  39.  *      double y;
  40.  *
  41.  *  PROGRAMMER
  42.  *
  43.  *      Fred Fish
  44.  *      Tempe, Az 85281
  45.  *      (602) 966-8871
  46.  *
  47.  */
  48.  
  49. #include <stdio.h>
  50. #include "pml.h"
  51.  
  52. double sign (x, y)
  53. double x;
  54. double y;
  55. {
  56.     double rtnval;
  57.     
  58.     if (x > 0.0) {
  59.                 if (y > 0.0) 
  60.                         rtnval = x;
  61.                 else 
  62.                         rtnval = -x;
  63.     } 
  64.         else {
  65.                 if (y < 0.0) 
  66.                         rtnval = x;
  67.                 else 
  68.                         rtnval = -x;
  69.     }
  70.     return (rtnval);
  71. }
  72.